package graph;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class DiagramPanel extends JPanel {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	final private ArrayList<graph.Drawable> drawables;

    public DiagramPanel(ArrayList<graph.Drawable> drawables, int width, int height, Color bgColor) {
        this.drawables = drawables;
        setPreferredSize(new Dimension(width, height));
        setBorder(BorderFactory.createLineBorder(Color.BLACK));
        this.setBackground(bgColor);
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        synchronized (drawables) {
            for (Drawable d : drawables) {
                d.draw(g);
                
            }
        }
    }
}
